#ifndef FREE_CAMERA_H
#define FREE_CAMERA_H

#include <string>
#include "cg/cg.h"
#include "MyPhysics.h"

namespace PeanutQuest {

    class FreeCamera : public cg::Entity,
		public cg::IUpdateListener,
		public cg::IDrawListener,
		public cg::IReshapeEventListener
	{
    private:
		cg::Vector3d position;
		double upRotation[16], sideRotation[16];
		double _winWidth, _winHeight;
		cg::Vector3d front, side, up;
		cg::Quaterniond _orientation;

		float upAngle, sideAngle;
		bool translate_front, translate_back;
		bool _isGoAhead, _isGoBack;
		bool _isTurnLeft, _isTurnRight;

		double _linearVelocity;
		double _angularVelocity;

		double _rotationMatrix[16];
		cg::Quaterniond _q;

		bool active;

    public:
        FreeCamera(std::string id);
        virtual ~FreeCamera();
        void init();
		bool getActive();
		void turnActive();
		void goAhead();
		void goBack();
		void turnLeft();
		void turnRight();
		void update(unsigned long elapsed_millis);
		void step(double elapsed_seconds);
		void rotate(double elapsed_seconds,int direction, cg::Vector3d axis, cg::Vector3d& v1, cg::Vector3d& v2);
        void draw();
        void onReshape(int width, int height);

	};
}

#endif
